Skip to content

Conversation

MarcoGorelli
Copy link
Member

This has uncovered a couple of bugs:

so some tests have their assertions ignored for now, but i've linked to them in those places

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Aug 26, 2025

@MarcoGorelli pine me when I should review

@MarcoGorelli MarcoGorelli marked this pull request as ready for review August 26, 2025 17:47
@MarcoGorelli
Copy link
Member Author

sure @Dr-Irv , happy for you to take a look, thanks!

Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the orthogonal issue, can you add a comment in #1347 that says that this file will have to be updated as part of addressing that issue?

Otherwise looks good. Just some small stuff

Comment on lines +90 to +104
# bug upstream: https://github.com/pandas-dev/pandas/issues/62196
# check(
# assert_type(
# divmod(na, s_int),
# tuple[pd.Series, pd.Series],
# ),
# tuple,
# )
# check(
# assert_type(
# divmod(na, idx_int),
# tuple[pd.Index, pd.Index],
# ),
# tuple,
# )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK to leave this in, with the #pyright: ignore, because it works with mypy. Then just make the comment about how pyright has the bug.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pyright 1.1.405 should fix this, so can you try changing pyproject.toml to use that version and see if you can put the test back?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, have updated, it does indeed allow us to remove the # pyright: ignore

# assert_type(divmod(s_int, na), tuple[pd.Series, pd.Series]),
# tuple,
# )
# https://github.com/pandas-dev/pandas-stubs/issues/1347
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the bug upstream in pandas, not the orthogonal issue?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say this is both, here

# ),
# tuple,
# )
check(assert_type(na.__divmod__(1), tuple[NAType, NAType]), tuple)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i couldn't understand why, but this one fails if I write divmod(na, 1) instead, with

  /home/marcogorelli/pandas-stubs-dev/tests/test_natype.py:105:23 - error: No overloads for "divmod" match the provided arguments (reportCallIssue)
  /home/marcogorelli/pandas-stubs-dev/tests/test_natype.py:105:23 - error: "assert_type" mismatch: expected "tuple[NAType, NAType]" but received "Unknown" (reportAssertTypeFailure)
  /home/marcogorelli/pandas-stubs-dev/tests/test_natype.py:105:34 - error: Argument of type "Literal[1]" cannot be assigned to parameter "y" of type "SupportsRDivMod[_T_contra@divmod, _T_co@divmod]" in function "divmod"
    "Literal[1]" is incompatible with protocol "SupportsRDivMod[NAType, _T_co@divmod]"
      "__rdivmod__" is an incompatible type
        Type "(value: int, /) -> tuple[int, int]" is not assignable to type "(other: _T_contra@SupportsRDivMod, /) -> _T_co@SupportsRDivMod"
          Parameter 1: type "_T_contra@SupportsRDivMod" is incompatible with type "int"
            "NAType" is not assignable to "int" (reportArgumentType)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New pyright bug. microsoft/pyright#10899

Let's wait to get that resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants